<%@page import="Data.Category"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Data.Event"%>
<script  language="javascript" type="text/javascript">
    function CheckEvent() {
        var Event = document.getElementById("listEvent").value;

        if (Event == 1)
        {
            window.location.replace('index.jsp?page=EventNew');
        } else
        {
            window.location.replace('index.jsp?page=EventTookplace');
        }
    }
</script>
<section id="content" class="gray-area">
    <div class="container car-detail-page">
        <div class="row">
            <jsp:include page="menu-right.jsp" />
            <div class="col-sm-8 col-md-9">
                <div  class="sort-by-section clearfix">
                    <form action="../SearchClient" method="post" name="frmSearch" id="frmSearch">
                        <ul style="text-align: right; float: right;">
                            <li style="font-size: 14px;" class="loc"> <select onchange="CheckEvent();" name='listEvent' id="listEvent" style="min-width: 200px" class='listmenuloc'>
                                    <option  value="2">Select</option>
                                    <option  value="1">Event new</option>
                                    <option  value="0">Event Took place</option>
                                </select>
                            </li>
                            <li style="font-size: 14px;" class="loc"> <select name='listmenuloc' style="min-width: 200px" class='listmenuloc'>
                                    <option  value="1">CATEGORY</option>
                                    <%
                                        Category cte = new Category();
                                        ArrayList<Category> aca = cte.CselectbyQuery(" AND Status=1");

                                        if (aca.size() > 0) {
                                            for (int i = 0; i < aca.size(); i++) {
                                                Category categ = aca.get(i);

                                                out.print("<option  value='" + categ.getCategoryID() + "'>" + categ.getCategoryName() + "</option>");

                                            }
                                        }
                                    %>
                                </select>
                            </li>
                            <li><input style="width: 250px; height: 33px; background: #f5f5f5; border: none" type="text" name="txtSearch" id="txtSearch" placeholder=" Event name..." /></li>

                            <li><input type="submit" name="btnSearch" style='background:  #00A8FF; border: none; width: 120px; height: 33px; color: #fff;' value="Search" /></li>
                        </ul>
                    </form>


                </div>
                <div class="car-list row image-box listing-style2">
                    <%
                        Event ct = new Event();
                        ArrayList<Event> a;
                        if (session.getAttribute("sstimkiem") == null || session.getAttribute("sstimkiem") == "") {
                            if (request.getParameter("CateID") != null) {

                                int CateID = Integer.parseInt(request.getParameter("CateID"));
                                a = ct.ESelectbyQuery("SELECT * FROM Event Where CategoryID=" + CateID);
                                if (a.size() > 0) {
                                    for (int ic = 0; ic < a.size(); ic++) {
                                        Event event = a.get(ic);
                                        out.println("<div class='col-sms-6 col-sm-6 col-md-4'>");
                                        out.println("<article class='box'>");
                                        out.println("<figure>");
                                        out.println("<a href='index.jsp?page=detailEvent&EventID=" + event.getEventID() + "' title='' class='hover-effect'><img src='../uploads/" + event.getImages() + "' alt='' width='270' height='160' /></a>");
                                        out.println("</figure>");
                                        out.println("<div class='details'>");
                                        out.println("<a title='View Detailed' href='index.jsp?page=detailEvent&EventID=" + event.getEventID() + "' class='pull-right button btn-mini uppercase'>select</a>");
                                        out.println("<h4 class='box-title'>" + event.getEventName() + "</h4>");
                                        out.println("<label class='price-wrapper'>");
                                        out.println("<span class='price-per-unit'>$" + event.getPrice() + "</span>");
                                        out.println("</label>");
                                        out.println("</div>");
                                        out.println("</article>");
                                        out.println("</div>");
                                    }
                                }
                            } else {
                                a = ct.ESelect();
                                if (a.size() > 0) {
                                    for (int i = 0; i < a.size(); i++) {
                                        Event levt = a.get(i);
                                        out.println("<div class='col-sms-6 col-sm-6 col-md-4'>");
                                        out.println("<article class='box'>");
                                        out.println("<figure>");
                                        out.println("<a href='index.jsp?page=detailEvent&EventID=" + levt.getEventID() + "' title='' class='hover-effect'><img src='../uploads/" + levt.getImages() + "' alt='' width='270' height='160' /></a>");
                                        out.println("</figure>");
                                        out.println("<div class='details'>");
                                        out.println("<a title='View Detailed' href='index.jsp?page=detailEvent&EventID=" + levt.getEventID() + "' class='pull-right button btn-mini uppercase'>select</a>");
                                        out.println("<h4 class='box-title'>" + levt.getEventName() + "</h4>");
                                        out.println("<label class='price-wrapper'>");
                                        out.println("<span class='price-per-unit'>$" + levt.getPrice() + "</span>");
                                        out.println("</label>");
                                        out.println("</div>");
                                        out.println("</article>");
                                        out.println("</div>");
                                    }
                                }
                            }
                        } else {
                            a = new Event().getArrEvent();
                            if (a.size() > 0) {
                                for (int i = 0; i < a.size(); i++) {
                                    Event cate = a.get(i);

                                    out.println("<div class='col-sms-6 col-sm-6 col-md-4'>");
                                    out.println("<article class='box'>");
                                    out.println("<figure>");
                                    out.println("<a href='index.jsp?page=detailEvent&EventID=" + cate.getEventID() + "' title='' class='hover-effect'><img src='../uploads/" + cate.getImages() + "' alt='' width='270' height='160' /></a>");
                                    out.println("</figure>");
                                    out.println("<div class='details'>");
                                    out.println("<a title='View Detailed' href='index.jsp?page=detailEvent&EventID=" + cate.getEventID() + "' class='pull-right button btn-mini uppercase'>select</a>");
                                    out.println("<h4 class='box-title'>" + cate.getEventName() + "</h4>");
                                    out.println("<label class='price-wrapper'>");
                                    out.println("<span class='price-per-unit'>$" + cate.getPrice() + "</span>");
                                    out.println("</label>");
                                    out.println("</div>");
                                    out.println("</article>");
                                    out.println("</div>");
                                }
                            }
                            session.setAttribute("sstimkiem", "");
                        }
                    %>


                </div>
                    <a href="#" style="margin-bottom: 20px;" class="button uppercase full-width btn-large">load more listings</a>
            </div>


        </div>
    </div>
</section>